
# "@(#) $Id: FunctionWidget.py,v 1.1.1.1 2006-07-27 03:16:08 gioshe Exp $"
#
# This work is released under the GNU GPL, version 2 or later.
#
from Utils.kdeemul import *
from MultiPushButton import *
from Utils.Paths import *
from Utils.Settings import *



class FunctionWidget(QPushButton):
	def __init__(self,container = None):
		QPushButton.__init__(self,container)
		self.buildControls()
		self.state=None
		backColor=QColor(Settings.settings().get('ColorR'),Settings.settings().get('ColorG'),Settings.settings().get('ColorB'))
		self.setPaletteBackgroundColor(backColor)
		self.setFlat(True)
		self.setFixedWidth(80)
		self.setPaletteForegroundColor(QColor(80,80,80))
		font=QFont()
		font.setBold(True)
		font.setPointSize(12)
		self.setFont(font)
		QObject.connect(self,SIGNAL('clicked()'),self.onClick)

	def buildControls(self):
		#layout = QVBoxLayout(self)
		#iconbrowse = QIconSet(QPixmap(art("buttonbrowse.png")))
		#iconburnoff = QIconSet(QPixmap(art("buttonburnoff.png")))
		#iconburnon = QIconSet(QPixmap(art("buttonburnon.png")))
		#iconoptions = QIconSet(QPixmap(art("buttonoptions.png")))
		#iconrefresh = QIconSet(QPixmap(art("buttonrefresh.png")))
		#iconimport = QIconSet(QPixmap(art("buttonimport.png")))
		#iconsync = QIconSet(QPixmap(art("buttonimport.png")))
		#self.functionButton = PixmapMultiPushButton("",self)
		#layout.addWidget(self.functionButton)
		self.setText("Browse")
		self.state='browse'
		#self.label = QLabel("Browse",self)
		#self.label.setAlignment(Qt.AlignBottom)
		#self.setFixedHeight(50)
		#self.setPaletteBackgroundColor(QColor(172,191,238))
		#self.setFixedWidth(80)
		#layout.addWidget(self.label)
		
		QObject.connect(self,PYSIGNAL("setState"),self.setState)
		
	def setState(self,state):
		self.state=state
		print state
		if state=='browse':	self.setText("Browse")
		elif state=="burn":	self.setText("Burning")
		elif state=="import":	self.setText("Import")
		elif state=="sync":	self.setText("Sync")
		elif state=="refresh":	self.setText("Refresh")
		elif state=="burnoff":	self.setText("Burning disabled")
		elif state=="burnon":	self.setText("Burn")
			
		
	def onClick(self):
		if self.state=='browse':	self.emit(PYSIGNAL('browse'),(self,None))
		elif self.state=='burn':	self.emit(PYSIGNAL('burn'),(self,None))
		elif self.state=='burnoff':	self.emit(PYSIGNAL('burnoff'),(self,None))
		elif self.state=='burnon':	self.emit(PYSIGNAL('burnon'),(self,None))
		elif self.state=='import':	self.emit(PYSIGNAL('import'),(self,None))
		elif self.state=='sync':	self.emit(PYSIGNAL('sync'),(self,None))
		elif self.state=='refresh':	self.emit(PYSIGNAL('refresh'),(self,None))

